﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace INSTA_ORM
{
    class MappingInfo
    {
        private static MappingInfo instance;

        private MappingInfo()
        {}

        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        public static MappingInfo getInstance()
        {
            if(instance == null) {
                instance = new MappingInfo();
                XmlUtil xmlUtil = new XmlUtil();
                classMappingData = xmlUtil.openXML();
            }
            return instance;
        }

        private static IList<ClassMapping> classMappingData;

        public IList<ClassMapping> getClassMappingData()
        {
            return classMappingData;
        }

        public ClassMapping findMappingInfosByClassName(string className) {
            ClassMapping defaultClassMapping = null;
            foreach(var classMapping in classMappingData) {
                if(classMapping.ClassName == className) {
                    return classMapping;
                }
            }
            return defaultClassMapping;
        }
    }
}
